home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 52
/
Mac Magazin and MacEasy Magazine CD - Issue 52.iso
/
Updates
/
Stata 5.0 Ado-files
/
ado.sea
/
newado
/
matrix.hlp
< prev
next >
Wrap
Text File
|
1998-11-22
|
8KB
|
280 lines
.-
help for ^matrix^ (manual: ^[R] matrix^)
.-
Summary of matrix commands
--------------------------
Comments are provided below under the headings
1. Inputting matrices by hand
2. Obtaining copies of system matrices
3. Accumulating cross-product matrices
4. Matrix operators
5. Matrix functions
6. Eigenvalues and eigenvectors of symmetric matrices
7. Singular value decomposition
8. Matrix functions returning scalars
9. Macro extended functions regarding matrices
10. Submatrix extraction
11. Submatrix placement
12. Generating scores from coefficient vectors
13. Setting row and column names
14. Posting and redisplaying estimation results
15. Constraint processing
16. Matrix utilities
In the syntax diagrams, capital letters A, B, ..., Z stand for matrix names.
Full details can be found in ^[R] matrix^.
1. Inputting matrices by hand (see ^[R] matrix^ and ^[R] matrix define^)
---------------------------------------------------------------------
^mat^rix A ^= (^#[^,^#...] [^\^ #[^,^#...] [^\^ [...]]]^)^
Examples: . ^matrix mymat = (1,2\3,4)^
. ^matrix myvec = (1.7, 2.93, -5, 3)^
. ^matrix mycol = (1.7\ 2.93\ -5\ 3)^
2. Obtaining copies of system matrices (see ^[R] matrix get^)
------------------------------------------------------------
^mat^rix A ^= get(^systemname^)^
where systemname is
^_b^ coefficients after estimation
^VCE^ covariance matrix of estimators after estimation
^Rr^ constraint matrix after @test@
^Cns^ constraint matrix after estimation
^Ld^ factor loadings after @factor@
^Ev^ eigenvalues after @factor@
^Psi^ uniquenesses after @factor@
^Co^ correlation matrix after @factor@
^SD^ standard deviations after @factor@
^Mean^ means after @factor@
Examples: . ^matrix coefs = get(_b)^
. ^matrix V = get(VCE)^
3. Accumulating cross-product matrices (see ^[R] matrix accum^)
--------------------------------------------------------------
^mat^rix ^ac^cum A ^=^ varlist [weight] [^if^ exp] [^in^ range]
[^, d^eviations ^m^eans^(^M^) noc^onstant ]
^mat^rix ^glsa^ccum A ^=^ varlist [weight] [^if^ exp] [^in^ range]^,^
^gr^oup^(^groupvar^) gl^smat^(^{W|stringvar}^) r^ow^(^rowvar^)^
[^noc^onstant]
^mat^rix ^veca^ccum A ^=^ varlist [weight] [^if^ exp] [^in^ range] [^, noc^onstant]
Examples: . ^matrix accum XpX = price weight mpg^
(see ^[R] matrix accum^ for examples of ^glsaccum^ and ^vecaccum^)
4. Matrix operators (see ^[R] matrix define^)
--------------------------------------------
^mat^rix A ^=^ B (assignment)
^mat^rix A ^=^ B^'^ (transposition)
^mat^rix A ^=^ B ^+^ C (addition)
^mat^rix A ^=^ B ^-^ C (subtraction)
^mat^rix A ^=^ B[^'^] ^*^ C[^'^] (multiplication)
^mat^rix A ^=^ B ^#^ C (Kronecker product)
^mat^rix A ^=^ B ^,^ C (join rows)
^mat^rix A ^=^ B ^\^ C (join columns)
Examples: . ^matrix b = XpXinv * Xpy^
. ^matrix big = big , newcol^
. ^matrix big = big \ newrow^
5. Matrix functions (see ^[R] matrix define^)
--------------------------------------------
^mat^rix A ^= I(^#^)^ (identity matrix)
^mat^rix A ^= J(^#^,^#^,^#^)^ (r x c matrix containing z)
^mat^rix A ^= cholesky(^B^)^ (Cholesky decomposition)
^mat^rix A ^= syminv(^B^)^ (inverse of symmetric matrix)
^mat^rix A ^= inv(^B^)^ (inverse of general matrix)
^mat^rix A ^= sweep(^B^,^#^)^ (sweep operator)
^mat^rix A ^= corr(^B^)^ (correlation from covariance)
^mat^rix A ^= diag(^B^)^ (extract diagonal into vector)
^mat^rix A ^= vecdiag(^B^)^ (make diagonal matrix from
vector)
Examples: . ^matrix id3 = I(3)^
. ^matrix zeros = J(2,3,0)^
. ^matrix XpXinv = syminv(XpX)^
6. Eigenvalues and eigenvectors of symmetric matrices (see ^[R] matrix symeigen^)
-------------------------------------------------------------------------------
Given n x n, symmetric matrix A,
^mat^rix ^syme^igen X V ^=^ A
returns the eigenvectors in the columns of X: n x n and the corresponding
eigenvalues in V: 1 x n. The eigenvalues are sorted from largest to
smallest: V[1,1] contains the largest eigenvector and X[.,1] its corresponding
eigenvector; V[1,2] contains the second largest eigenvector and X[.,2] its
corresponding eigenvector, and so on.
7. Singular value decomposition (see ^[R] matrix svd^)
-----------------------------------------------------
Given m x n matrix A, m>=n,
^mat^rix ^svd^ U W V ^=^ A
returns U: m x n, W: 1 x n, and V: n x n such that:
A = U diag(W) V'
In addition, U is column orthogonal, the elements of W are positive or zero,
and V'V=I.
8. Matrix functions returning scalars (see ^[R] matrix^)
-------------------------------------------------------
The following may be used anyplace an exp is allowed:
^trace(^A^)^
^rowsof(^A^)^
^colsof(^A^)^
^roweq(^A^,^string^)^
^coleq(^A^,^string^)^
^det(^A^)^
^A[^exp^,^exp^]^ or ^el(^{A|string}^,^exp^,^exp^)^
^matrix(^A^)^
Examples: . ^scalar a = det(A)^
. ^gen value = A[famrel,2]^
9. Macro extended functions regarding matrices (see ^[R] matrix^)
----------------------------------------------------------------
The following extended functions are allowed with ^local^ and ^global^:
^: rownames(^A^)^
^: colnames(^A^)^
^: roweq(^A^)^
^: coleq(^A^)^
Example: . local names : rownames(mymat)
10. Submatrix extraction (see ^[R] matrix define^)
-------------------------------------------------
^mat^rix A ^=^ B^[^<range>^,^<range>^]^
where <range> is
# "name"
#^..^# "name"^..^"name"
#^...^ "name"^...^
"eqname^:^"
Examples: . ^matrix sub = master[2..4, 3..7]^
. ^matrix sub = master["price".."weight", 3..7]^
. ^matrix X = Z[2..., 2...]^
. ^matrix eq1 = Z["eq1:", 2...]^
11. Submatrix placement (see ^[R] matrix substitute^)
----------------------------------------------------
^mat^rix ^sub^stitute A[#,#] = B
Example: . ^matrix A[2,2] = submat^
12. Generating scores from coefficient vectors (see ^[R] matrix score^)
----------------------------------------------------------------------
^mat^rix ^sco^re [type] newvar ^=^ B [^if^ exp] [^in^ range]
where B is 1 x n or n x 1.
Example: . matrix score index = coefs
13. Setting row and column names (see ^[R] matrix rowname^)
----------------------------------------------------------
^mat^rix ^rown^ames A ^=^ name [name [...]]
^mat^rix ^coln^ames A ^=^ name [name [...]]
^mat^rix ^rowe^q A ^=^ name [name [...]]
^mat^rix ^cole^q A ^=^ name [name [...]]
where name is
(1) a simple name
(2) a colon followed by a simple name
(3) an equation name followed by a colon
(4) an equation name, a colon, and a simple name
(1) is interpreted as a subname by ^rownames^ and ^colnames^ and as an equation
name by ^roweq^ and ^coleq^.
Example: . ^matrix rownames A = price weight mpg^
14. Posting and redisplaying estimation results (see ^[R] matrix post^)
----------------------------------------------------------------------
^mat^rix ^post^ b V [C] [^, dep^name^(^name^) o^bs^(^#^) d^of^(^#^)^]
^mat^rix ^mlou^t [^, ef^orm^(^string^) f^irst ^l^evel^(^#^)^]
See ^[R] matrix post^ for examples of these commands.
15. Constraint processing (see ^[R] matrix constraint^)
------------------------------------------------------
^mat^rix ^makeCns^ [clist]
^mat^rix ^dispCns^
^matcproc^ T a C
See ^[R] matrix constraint^ for examples of these commands.
16. Matrix utilities (see ^[R] matrix utility^)
----------------------------------------------
^mat^rix ^d^ir
^mat^rix ^l^ist A [^, nob^lank ^noha^lf ^noh^eader ^non^ames ^f^ormat^(^%fmt^)^
^t^itle^(^string^)^ ]
^mat^rix ^drop^ { ^_all^ | A [B [...]] }
Examples: . ^matrix list mymat^
. ^mat drop mymat^
Also see
--------
Manual: ^[R] matrix^
On-line: help for @mkmat@, @ml@